import Vue from 'vue'
import App from './App'
import store from './store'
import router from './router'
import api from './http'
import i18n from './i18n'
import global from '@/utils/global'
import ElementUI from 'element-ui'
import axios from 'axios'
import 'element-ui/lib/theme-chalk/index.css'
import 'font-awesome/css/font-awesome.min.css'

axios.defaults.withCredentials = true

Vue.use(ElementUI) // 注册使用Element
Vue.use(api) // 注册使用API模块

Vue.prototype.global = global // 挂载全局配置模块
// 路由拦截器，如果Cookie中没有token 就重定向到登录页面
/* router.beforeEach((to, from, next) => {
  if (to.path === '/login') {
    next()
  } else {
    let token = Cookies.get('token')
    if (token) {
      next()
    } else {
      next('/login')
    }
  }
}) */
/* eslint-disable no-new */
new Vue({
  el: '#app',
  i18n,
  router,
  store,
  components: { App },
  template: '<App/>'
})
